﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YmtAuth.Domain.Model.Safe
{

    public class AuthSafeHandleCode
    {
        /// <summary>
        /// 需要身份认证 100
        /// </summary>
        public const int NeedIdentityVerify = 100;
        /// <summary>
        /// 继续执行下一个安全认证流程 200
        /// </summary>
        public const int ContinueNextVerify = 200;
        /// <summary>
        /// 允许用户登录 300
        /// </summary>
        public const int AllowLogin = 300;
        /// <summary>
        /// 拒绝登录  400
        /// </summary>
        public const int DenyLogin = 400;
        /// <summary>
        /// 登录密码错误 500
        /// </summary>
        public const int LoginPasswordError = 500;
        /// <summary>
        /// 登录ID错误  600
        /// </summary>
        public const int LoginIdError = 600;
        /// <summary>
        /// 原始IP库数据不存在  700
        /// </summary>
        public const int RawIpNotFind = 700;
        /// <summary>
        /// IP区域未认证 800
        /// </summary>
        public const int IPAreaNotAuth = 800;
        /// <summary>
        /// IP区域认证失败 900
        /// </summary>
        public const int IPAreaAuthFail = 900;
        /// <summary>
        /// IP区域认证成功 1000
        /// </summary>
        public const int IPAreaAuthSuccess = 1000;
        /// <summary>
        /// 最后一次token认证数据不存在 1100
        /// </summary>
        public const int TokeLastAuthNotFine = 1100;
        /// <summary>
        /// 客户端身份认证失败 1200
        /// </summary>
        public const int ClientAuthFail = 1200;
        /// <summary>
        /// DB执行操作失败 1300
        /// </summary>
        public const int DbExecuteFail = 1300;
        /// <summary>
        /// 登录成功 1400
        /// </summary>
        public const int LoginSuccess = 1400;

        /// <summary>
        /// 非法的登录名
        /// </summary>
        public const int LoginIdFormartError = 1500;

        public const int LoginUserBlackList = 1600;

        public const int LoginBlackIP = 2700;

        /// <summary>
        /// 登录ID超过登录限制
        /// </summary>
        public const int LoginCountGTLimit = 1700;
        /// <summary>
        /// APP请求，clientID，DeviceId都为空则直接返回错误
        /// </summary>
        public const int AppFormartError = 1800;

        public const int AppDeviceClientVerifyFail = 1900;
        public const int AppDeviceAuthSuccess = 2000;
        public const int UserDeviceFirstAutoAuth = 2100;
        public const int UserIpAreaFirstAutoAuth = 2100;
        public const int UserDeviceIsEmpty = 2200;
        public const int UserSafeVerifyDeviceIsEmpty = 2300;
        public const int LoginIPBlackList = 2400;
        /// <summary>
        /// IP区域数据在，认证库库不存在 2500
        /// </summary>
        public const int IpAreaNotExists = 2500;
        /// <summary>
        /// 用户第一次登录
        /// </summary>
        public const int UserFirstLogin = 2600;

        /// <summary>
        /// 更新设备认证状态失败 2800
        /// </summary>
        public const int DeviceAuthUpdateFail = 2800;

        /// <summary>
        /// 更新设备认证状态成功 2900
        /// </summary>
        public const int DeviceAuthUpdateSuccess = 2900;

        /// <summary>
        /// 更新IP区域认证状态失败（身份认证后调用） 3000
        /// </summary>
        public const int IPAreaAuthUpdateFail = 3000;
        /// <summary>
        /// 更新IP区域认证状态成功（身份认证后调用） 3000
        /// </summary>
        public const int IPAreaAuthUpdateSuccess = 3100;

        /// <summary>
        /// 禁用买手邮箱登陆
        /// </summary>
        public const int DisableSellerMailLogin = 3200;
        /// <summary>
        /// 白名单IP
        /// </summary>
        public const int WhitelistIp = 3300;

        /// <summary>
        /// IP区域认证-客户端安全问题需要验证 3400
        /// </summary>
        public const int AppIpAreaClientNeedVerifySecurityQuestion = 3400;

        /// <summary>
        /// 设备认证-客户端安全问题需要验证 3500
        /// </summary>
        public const int AppDeviceClientNeedVerifySecurityQuestion = 3500;

        public const int SMSIpAuth = 4000;
        public const int SMSDeviceAuth = 4000;
        /// <summary>
        /// 100： 需要用户身份验证；200： 继续执行安全认证流程；300：用户可以直接登录
        /// </summary>
        public int Code { get; private set; }
        /// <summary>
        /// 返回给业务端的提示
        /// </summary>
        public string ResponseMessage { get; private set; }

        /// <summary>
        /// 具体的错误码
        /// </summary>
        public int SubCode { get; private set; }
      
        /// <summary>
        /// 具体验证消息
        /// </summary>
        public string Message { get; private set; }
        /// <summary>
        /// 创建验证结果code
        /// </summary>
        /// <param name="code"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static AuthSafeHandleCode CreateCode(int code, string message = null, string authMessage = null)
        {
            return new AuthSafeHandleCode() { Code = code, SubCode = code, Message = message, ResponseMessage = authMessage };
        }

        public static AuthSafeHandleCode CreateCode(int code, int subCode, string message = null, string authMessage = null)
        {
            return new AuthSafeHandleCode() { Code = code, SubCode = subCode, Message = message, ResponseMessage = authMessage };
        }

        public void SetCode(int code)
        {
            this.Code = code;
        }

        public override string ToString()
        {
            return string.Format(" code:{0}, SubCode:{1}, msg:{2}", Code, SubCode, Message);
        }
    }
}
